// https://leetcode.cn/problems/determine-the-winner-of-a-bowling-game/


func isWinner(player1 []int, player2 []int) int {
    a, b := player1[0], player2[0]
	n = len(player1)
	if n > 1 {
		a += player1[1]
		b += player2[1]
		for i := 2; i < n; i++ {
			if player1[i - 1] == 10 or player1[i - 2] == 10 {
				a += 2 * player1[i]
			} else {
				a += player1[i]
			}
			if player2[i - 1] == 10 or player2[i - 2] == 10 {
				b += 2 * player2[i]
			} else {
				b += player2[i]
			}
		}
	}
	if a > b {
		return 1
	} else if a < b {
		return 2
	} else {
		return 0
	}

}